﻿using AutoMapper;
using Rj.PersonnelVerification.Server.DataBaseContext.Entities;
using Rj.PersonnelVerification.Server.Models.VerificationNode;
using Rj.PersonnelVerification.Shared.Models.Response;
using System.Globalization;

namespace Rj.PersonnelVerification.Server.MapperProfile
{
    public class VerificationServerMapperProfile : Profile
    {
        public VerificationServerMapperProfile()
        {
            SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
            DestinationMemberNamingConvention = new PascalCaseNamingConvention();
            CreateMap<IoTbInPatient, QueryNoUploadResponse>();
            CreateMap<IoTbPersonnelInfoNew, Verification2401BaseInfo>()
                .ForMember(f=>f.psn_name,i=>i.MapFrom(f=>f.PsnName))
                .ForMember(f=>f.psn_cert_type,i=>i.MapFrom(f=>f.PsnCertType))
                .ForMember(f=>f.psn_no,i=>i.MapFrom(f=>f.PsnNo));
                //.ForMember(f => f.brdy, i => i.MapFrom(f => { DateTime.TryParseExact(f.Brdy, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime); return dateTime; }));
            CreateMap<IoTbPersonnelInfoNew, Verification2401InsuInfo>()
                .ForMember(f=>f.paus_insu_date,i=>i.MapFrom(f=>f.PausInsuDate))
                .ForMember(f=>f.psn_insu_date,i=>i.MapFrom(f=>f.PsnInsuDate))
                .ForMember(f=>f.cvlserv_flag,i=>i.MapFrom(f=>f.CvlservFlag))
                .ForMember(f=>f.emp_name,i=>i.MapFrom(f=>f.EmpName))
                .ForMember(f=>f.insuplc_admdvs,i=>i.MapFrom(f=>f.InsuplcAdmdvs))
                .ForMember(f=>f.psn_type,i=>i.MapFrom(f=>f.PsnType));
            CreateMap<RegisterMdtrtinfoParams, Verification2401MdtrtInfo>();
            CreateMap<LeaveHospitalDscginfoParams, Verification2402DscgInfo>();
        }
    }
}
